<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yuzhenxin.gitee.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="LinuxLinux常见命令 pwd：显示当前所在目录路径 ls和ll：列出当前目录所有文件，后者更详细 touch xx：新建文件xx rm xx：删除文件xx mkdir：新建目录 rm -r xx：删除文件夹xx mv 文件名 文件夹名 clear和reset history  rpm安装与卸载 rpm -ivh –nodeps XXX.rpm rpm -qa|grep XXX rpm -e">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux">
<meta property="og:url" content="http://yuzhenxin.gitee.io/2021/01/20/Linux/index.html">
<meta property="og:site_name" content="余振鑫的Hexo博客">
<meta property="og:description" content="LinuxLinux常见命令 pwd：显示当前所在目录路径 ls和ll：列出当前目录所有文件，后者更详细 touch xx：新建文件xx rm xx：删除文件xx mkdir：新建目录 rm -r xx：删除文件夹xx mv 文件名 文件夹名 clear和reset history  rpm安装与卸载 rpm -ivh –nodeps XXX.rpm rpm -qa|grep XXX rpm -e">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/yuzhenxin/images/raw/master/img/20210318102251.png">
<meta property="og:image" content="https://gitee.com/yuzhenxin/images/raw/master/img/20210318102155.png">
<meta property="article:published_time" content="2021-01-19T16:00:00.000Z">
<meta property="article:modified_time" content="2022-01-20T11:55:05.380Z">
<meta property="article:author" content="余振鑫">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/yuzhenxin/images/raw/master/img/20210318102251.png">

<link rel="canonical" href="http://yuzhenxin.gitee.io/2021/01/20/Linux/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Linux | 余振鑫的Hexo博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">余振鑫的Hexo博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">计算机笔记</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yuzhenxin.gitee.io/2021/01/20/Linux/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="余振鑫">
      <meta itemprop="description" content="余振鑫的个人博客">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="余振鑫的Hexo博客">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Linux
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-20 00:00:00" itemprop="dateCreated datePublished" datetime="2021-01-20T00:00:00+08:00">2021-01-20</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-01-20 19:55:05" itemprop="dateModified" datetime="2022-01-20T19:55:05+08:00">2022-01-20</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Linux"><a href="#Linux" class="headerlink" title="Linux"></a>Linux</h1><h2 id="Linux常见命令"><a href="#Linux常见命令" class="headerlink" title="Linux常见命令"></a>Linux常见命令</h2><ul>
<li>pwd：显示当前所在目录路径</li>
<li>ls和ll：列出当前目录所有文件，后者更详细</li>
<li>touch xx：新建文件xx</li>
<li>rm xx：删除文件xx</li>
<li>mkdir：新建目录</li>
<li>rm -r xx：删除文件夹xx</li>
<li>mv 文件名 文件夹名</li>
<li>clear和reset</li>
<li>history</li>
</ul>
<h3 id="rpm安装与卸载"><a href="#rpm安装与卸载" class="headerlink" title="rpm安装与卸载"></a>rpm安装与卸载</h3><ul>
<li>rpm -ivh –nodeps XXX.rpm</li>
<li>rpm -qa|grep XXX</li>
<li>rpm -e –nodeps 软件包（上面的结果）</li>
</ul>
<h3 id="开放端口"><a href="#开放端口" class="headerlink" title="开放端口"></a>开放端口</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">## 查看防火墙状态</span></span><br><span class="line">systemctl status firewalld</span><br><span class="line"><span class="comment">## 开启端口</span></span><br><span class="line">firewall-cmd --zone=public --add-port=8080/tcp --permanent</span><br><span class="line"><span class="comment">## 重启防火墙</span></span><br><span class="line">firewall-cmd --reload</span><br><span class="line"><span class="comment">## 查询开放端口</span></span><br><span class="line">firewall-cmd --list-port</span><br><span class="line"><span class="comment">## 重启docker</span></span><br><span class="line">systemctl restart docker</span><br><span class="line"></span><br><span class="line"><span class="comment">## 启动docker（Ubuntu）</span></span><br><span class="line">sudo service docker start</span><br></pre></td></tr></table></figure>

<p><img src="https://gitee.com/yuzhenxin/images/raw/master/img/20210318102251.png" alt="image-20210316165836806"></p>
<h3 id="Centos配置Java环境变量"><a href="#Centos配置Java环境变量" class="headerlink" title="Centos配置Java环境变量"></a>Centos配置Java环境变量</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/profile</span><br></pre></td></tr></table></figure>

<p>添加：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">JAVA_HOME&#x3D;&#x2F;usr&#x2F;java&#x2F;jdk1.8.0_281</span><br><span class="line">PATH&#x3D;$PATH:$JAVA_HOME&#x2F;bin</span><br><span class="line">CLASSPATH&#x3D;.:$JAVA_HOME&#x2F;lib</span><br><span class="line">export JAVA_HOME PATH CLASSPATH</span><br><span class="line"></span><br><span class="line">JAVA_HOME&#x3D;&#x2F;usr&#x2F;java&#x2F;jdk-11.0.7</span><br><span class="line">PATH&#x3D;$PATH:$JAVA_HOME&#x2F;bin</span><br><span class="line">export PATH JAVA_HOME</span><br></pre></td></tr></table></figure>

<h2 id="Git"><a href="#Git" class="headerlink" title="Git"></a>Git</h2><p><strong>分布式版本控制</strong>，对比SVN集中版本控制：</p>
<ul>
<li>SVN所有版本数据保存在服务器，开发者从服务器上同步</li>
<li>Git中每个人都有仓库全部信息，防止服务器损坏导致数据丢失。</li>
</ul>
<h3 id="常见命令"><a href="#常见命令" class="headerlink" title="常见命令"></a>常见命令</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看配置文件</span></span><br><span class="line">git config -l</span><br><span class="line"></span><br><span class="line"><span class="comment">#配置用户属性</span></span><br><span class="line">git config --global user.name <span class="string">&quot;yuzhenxin&quot;</span></span><br><span class="line">git config --global user.email <span class="string">&quot;1399079216@qq.com&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#查看系统配置</span></span><br><span class="line">git config --system --list</span><br><span class="line"></span><br><span class="line"><span class="comment">#查看当前用户配置</span></span><br><span class="line">git config --global --list</span><br><span class="line"></span><br><span class="line">// <span class="built_in">local</span>仓库级别 -&gt; global用户级别 -&gt; system系统级别</span><br><span class="line">git config --<span class="built_in">local</span> paper.branch <span class="literal">false</span></span><br><span class="line"></span><br><span class="line">// 注意等号前后不能有空格</span><br><span class="line">git branch --set-upstream-to=origin/coding-yzx</span><br><span class="line"></span><br><span class="line">// 分支改名</span><br><span class="line">git branch -m a b</span><br><span class="line"></span><br><span class="line">// 使.gitignore生效</span><br><span class="line">git rm -r --cached .</span><br><span class="line">git add .</span><br><span class="line">git commit -m <span class="string">&quot;.gitignore now work&quot;</span></span><br></pre></td></tr></table></figure>

<p>系统配置文件路径：D:\Programming\Git\etc\gitconfig</p>
<p>用户配置文件路径：‪C:\Users\YuZhenXin.gitconfig</p>
<h3 id="基本理论"><a href="#基本理论" class="headerlink" title="基本理论"></a>基本理论</h3><p><img src="https://gitee.com/yuzhenxin/images/raw/master/img/20210318102155.png" alt="image-20210306215824413"></p>
<p><strong>创建仓库：</strong></p>
<ul>
<li>git init</li>
<li>git clone [url]</li>
</ul>
<p>Working Directory工作区：存放代码的地方</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git add .</span><br></pre></td></tr></table></figure>

<p>Stage暂存区：保存即将提交的文件列表信息</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git commit -m <span class="string">&quot;修改信息&quot;</span></span><br></pre></td></tr></table></figure>

<p>Repository本地仓库</p>
<p>Remote远程仓库</p>
<p><strong>忽略文件提交</strong>：主目录下.gitignore</p>
<h3 id="配置远程仓库"><a href="#配置远程仓库" class="headerlink" title="配置远程仓库"></a>配置远程仓库</h3><ul>
<li><p>在C:\Users\YuZhenXin\.ssh下运行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa</span><br></pre></td></tr></table></figure></li>
<li><p>‪将C:\Users\YuZhenXin\.ssh\id_rsa.pub内容粘贴到Gitee生成SSH公钥</p>
</li>
<li><p>创建仓库</p>
</li>
<li><p>git clone [url]（注意选择ssh链接！）</p>
</li>
</ul>
<h3 id="分支"><a href="#分支" class="headerlink" title="分支"></a>分支</h3><p><strong>分支相当于一棵树（图），根节点为最初版本，不同路径代表不同分支。通过git checkout选择不同分支进行操作，最终希望不同分支会合master</strong></p>
<p>git merge xx表示指向xx（xx为父节点）</p>
<p>git xx rebase yy会将xx分支拉到yy下面（xx指向yy）</p>
<p>git checkout可以指向结点</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看分支</span></span><br><span class="line">git branch</span><br><span class="line"><span class="comment">#查看远程分支</span></span><br><span class="line">git branch -r</span><br><span class="line"></span><br><span class="line"><span class="comment">#新建分支(仍在原分支)</span></span><br><span class="line">git branch xx</span><br><span class="line"><span class="comment">#切换分支</span></span><br><span class="line">git checkout xx</span><br><span class="line"><span class="comment">#创建分支并跳转到该分支</span></span><br><span class="line">git checkout -b xx</span><br><span class="line"></span><br><span class="line"><span class="comment">#合并ab分支：在a分支下</span></span><br><span class="line">git merge b</span><br><span class="line"></span><br><span class="line"><span class="comment">#删除分支</span></span><br><span class="line">git branch -d xx</span><br><span class="line"><span class="comment">#删除远程分支</span></span><br><span class="line">git branch -dr xx</span><br></pre></td></tr></table></figure>

<h2 id="Hexo博客"><a href="#Hexo博客" class="headerlink" title="Hexo博客"></a>Hexo博客</h2><h3 id="准备（与当前目录无关）"><a href="#准备（与当前目录无关）" class="headerlink" title="准备（与当前目录无关）"></a>准备（与当前目录无关）</h3><p>npm install –registry=<a target="_blank" rel="noopener" href="https://registry.npm.taobao.org/">https://registry.npm.taobao.org</a></p>
<p>npm install -g cnpm –registry=<a target="_blank" rel="noopener" href="https://registry.npm.taobao.org/">https://registry.npm.taobao.org</a></p>
<p>cnpm install -g hexo-cli</p>
<h3 id="本地部署"><a href="#本地部署" class="headerlink" title="本地部署"></a>本地部署</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#在博客目录下</span></span><br><span class="line">hexo init</span><br><span class="line"></span><br><span class="line"><span class="comment">#新建文件hello</span></span><br><span class="line">hexo n <span class="string">&quot;hello&quot;</span></span><br><span class="line"><span class="comment">#清除h</span></span><br><span class="line">hexo clean</span><br><span class="line"><span class="comment">#编译生成静态页面</span></span><br><span class="line">hexo g</span><br><span class="line"><span class="comment">#启动，预览localhost:4000</span></span><br><span class="line">hexo s</span><br><span class="line"></span><br><span class="line"><span class="comment">#远程部署</span></span><br><span class="line">cnpm install hexo-deployer-git --save</span><br><span class="line">修改_config.yml:</span><br><span class="line">	<span class="comment">#Deployment</span></span><br><span class="line">	deploy</span><br><span class="line">		<span class="built_in">type</span>: git</span><br><span class="line">		repo: git@gitee.com:yuzhenxin/yuzhenxin.git</span><br><span class="line">		branch: master</span><br><span class="line">hexo d</span><br><span class="line">	</span><br><span class="line"><span class="comment">#修改主题</span></span><br><span class="line">git <span class="built_in">clone</span> URL</span><br><span class="line">修改_config.yml:</span><br><span class="line">	theme: xxx</span><br><span class="line">hexo clean</span><br><span class="line">hexo g</span><br><span class="line">hexo d</span><br></pre></td></tr></table></figure>

<p>配置next主题具体参考</p>
<p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/7951e239ae04">https://www.jianshu.com/p/7951e239ae04</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/nightmare_dimple/article/details/86661502">https://blog.csdn.net/nightmare_dimple/article/details/86661502</a></p>
<h2 id="Docker"><a href="#Docker" class="headerlink" title="Docker"></a>Docker</h2><p>容器和镜像就类比实例对象和类</p>
<ul>
<li><p>获取镜像（安装包）：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull redis</span><br></pre></td></tr></table></figure></li>
<li><p>查看镜像：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br><span class="line">mkdir -p /usr/<span class="built_in">local</span>/docker/redis</span><br><span class="line">mkdir -p /usr/<span class="built_in">local</span>/docker/mysql</span><br></pre></td></tr></table></figure></li>
<li><p>创建redis容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 6379:6379 --name redis -v /usr/<span class="built_in">local</span>/docker/redis/redis.conf:/etc/redis/redis.conf -v /usr/<span class="built_in">local</span>/docker/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes</span><br></pre></td></tr></table></figure>

<p>以配置文件启动redis，加载容器内的conf文件，最终找到的是挂载的目录/usr/local/docker/redis/redis.conf</p>
</li>
<li><p>创建mysql容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 3306:3306 --name mysql -v /usr/<span class="built_in">local</span>/docker/mysql/conf:/etc/mysql/conf.d -v /usr/<span class="built_in">local</span>/docker/mysql/logs:/logs -v /usr/<span class="built_in">local</span>/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=yuzhenxin2758 -d -i mysql</span><br></pre></td></tr></table></figure>

<p>简化版：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=yuzhenxin2758 mysql</span><br></pre></td></tr></table></figure></li>
<li><p>创建rabbitmq容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 -v /usr/<span class="built_in">local</span>/docker/rabbitmq/data:/var/lib/rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=yuzhenxin2758 rabbitmq:3.8.8-management</span><br></pre></td></tr></table></figure></li>
<li><p>安装Nginx</p>
<figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">docker pull nginx:latest  <span class="comment">#拉取官方的最新版本的镜像</span></span><br><span class="line"></span><br><span class="line">docker images  <span class="comment">#查看是否已安装了 nginx</span></span><br><span class="line"></span><br><span class="line">docker <span class="keyword">run</span><span class="bash"> -d -p 8080:80 --name nginx -v /usr/<span class="built_in">local</span>/docker/nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf -v /usr/<span class="built_in">local</span>/docker/nginx/logs:/var/<span class="built_in">log</span>/nginx nginx</span></span><br><span class="line">docker <span class="keyword">run</span><span class="bash"> --name nginx -p 80:80 -d nginx  <span class="comment">#运行 nginx 容器</span></span></span><br><span class="line"></span><br><span class="line">docker exec -it <span class="number">299</span>b6d99cc1c bash  <span class="comment">#进入Nginx容器中</span></span><br><span class="line"><span class="comment"># 日志位置：/var/log/nginx/</span></span><br><span class="line"><span class="comment"># 配置文件位置：/etc/nginx/</span></span><br><span class="line"><span class="comment"># 项目位置：/usr/share/nginx/html</span></span><br></pre></td></tr></table></figure></li>
<li><p>查看容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker ps -a</span><br></pre></td></tr></table></figure></li>
<li><p>启动XXX容器</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker start XXX</span><br></pre></td></tr></table></figure></li>
<li><p>进入XXX容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">exec</span> -it XXX /bin/bash</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">## redis</span></span><br><span class="line">redis-cli</span><br><span class="line"></span><br><span class="line"><span class="comment">## mysql</span></span><br><span class="line">mysql -uroot -p</span><br><span class="line"></span><br><span class="line"><span class="comment">##退出容器</span></span><br><span class="line"><span class="built_in">exit</span></span><br></pre></td></tr></table></figure></li>
<li><p>关闭XXX容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker stop XXX</span><br></pre></td></tr></table></figure></li>
<li><p>移除XXX容器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rm XXX</span><br></pre></td></tr></table></figure></li>
<li><p>自启：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">## 设置XXX、YYY自启</span></span><br><span class="line">docker update --restart=always XXX YYY</span><br><span class="line"><span class="comment">## 设置mysql开机自动启动</span></span><br><span class="line">docker update mysql --restart=always</span><br></pre></td></tr></table></figure></li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/01/11/Java%E6%A1%86%E6%9E%B6/" rel="prev" title="Java框架">
      <i class="fa fa-chevron-left"></i> Java框架
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/02/07/%E9%A2%98%E7%9B%AE/" rel="next" title="题目">
      题目 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Linux"><span class="nav-number">1.</span> <span class="nav-text">Linux</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Linux%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.</span> <span class="nav-text">Linux常见命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#rpm%E5%AE%89%E8%A3%85%E4%B8%8E%E5%8D%B8%E8%BD%BD"><span class="nav-number">1.1.1.</span> <span class="nav-text">rpm安装与卸载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BC%80%E6%94%BE%E7%AB%AF%E5%8F%A3"><span class="nav-number">1.1.2.</span> <span class="nav-text">开放端口</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Centos%E9%85%8D%E7%BD%AEJava%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-number">1.1.3.</span> <span class="nav-text">Centos配置Java环境变量</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Git"><span class="nav-number">1.2.</span> <span class="nav-text">Git</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4"><span class="nav-number">1.2.1.</span> <span class="nav-text">常见命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%9F%BA%E6%9C%AC%E7%90%86%E8%AE%BA"><span class="nav-number">1.2.2.</span> <span class="nav-text">基本理论</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93"><span class="nav-number">1.2.3.</span> <span class="nav-text">配置远程仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%86%E6%94%AF"><span class="nav-number">1.2.4.</span> <span class="nav-text">分支</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Hexo%E5%8D%9A%E5%AE%A2"><span class="nav-number">1.3.</span> <span class="nav-text">Hexo博客</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%87%86%E5%A4%87%EF%BC%88%E4%B8%8E%E5%BD%93%E5%89%8D%E7%9B%AE%E5%BD%95%E6%97%A0%E5%85%B3%EF%BC%89"><span class="nav-number">1.3.1.</span> <span class="nav-text">准备（与当前目录无关）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2"><span class="nav-number">1.3.2.</span> <span class="nav-text">本地部署</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Docker"><span class="nav-number">1.4.</span> <span class="nav-text">Docker</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">余振鑫</p>
  <div class="site-description" itemprop="description">余振鑫的个人博客</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">9</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">余振鑫</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
